const getParameterByName = (name, url) => {
	if (!url) url = window.location.href;
	name = name.replace(/[\[\]]/g, '\\$&');
	var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
		results = regex.exec(url);
	if (!results) return null;
	if (!results[2]) return '';
	return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
const navTo = (url = '') => {
	url = String(url);
	if (url.indexOf('http') != -1) {
		var token = uni.getStorageSync('token') ? uni.getStorageSync('token') : '';
		// #ifdef H5
		token = btoa(token);
		// #endif
		if (url.indexOf('?') != -1) {
			url = url + '&JiuT=' + token;
		} else {
			url = url + '?JiuT=' + token;
		}
		// #ifdef APP-PLUS || MP-WEIXIN
		url = escape(url);
		uni.navigateTo({
			url: "../web/web-view?url=" + url
		})
		// #endif
		// #ifdef H5
		window.location.href = url;

		// #endif
	} else {
		if (url.indexOf('/individualism/user') !=-1 || url.indexOf('/index/index') != -1) {
			// if (url.indexOf('/goodlist/goodlist') != -1) {
			// 	uni.setStorageSync('goodlistType', getParameterByName('id', url));
			// }
			uni.switchTab({
				url
			})
		} else {
			uni.navigateTo({
				url
			})
		}
	}
}
export default navTo